<?php
	/*
	* 万座网-订单
	*/
	include_once("../inc/ini.php");		//通用函数包含文件
	require_once("func/function.php");
	require_once("func/order.class.php");
	require_once("func/prdouct.class.php");
	require_once("../manage/msg/api/msg_mdlAPI.php");
	
	isLogin();//验证用户是否登录，未登录跳转到登录页面
	user_mktime($_SESSION['time']);//验证是否登录超时
	$ord=new order();
	$pro=new product();
	$act = empty($act) ? '' : $act;
	switch($act){
		case "pay"://订单支付
			echo '正在付款中……';
			
			$ord->pay($id,$price);
			break;
		case "showDialog":
			$uinfo=getUserInfo();//用户信息
			$oinfo=$ord->getOrderDetail($id);//订单信息
			$tinfo=$pro->getTicketDetail($oinfo['Tord_tkt_id']);//门票信息
			$allPrice=$oinfo['Tord_num']*$tinfo['Tkt_price3']+$tinfo['Tkt_freight'];
			if($uinfo['mem_money']<$allPrice){
				include(ADMINI_TPL."choosepay.html");	
			}else{
				Location("order.php?act=pay&id=$id&price=$allPrice");
			}
			break;
		case "modify"://订单修改
			
			$detail=$ord->getOrderDetail($id);//订单详细
			$proDetail=$pro->getTicketDetail($detail['Tord_tkt_id']);//门票详细
			//dump($proDetail);
			if($proDetail['Tkt_name']==''){
				die('该景点门票已经下架');
			}
			$dateList=perDate($proDetail['Tkt_starttime'],$proDetail['Tkt_endtime'],strtotime(date('Y-m-d H:i:s')));
			include(ADMINI_TPL.'order_modify.html');
			break;
		case "msend"://修改提交
			$ord->modifyOrder();
			break;
		case "cancel"://订单撤销
			$ord->cancelOrder($id);
			break;
		case "list"://订单列表
			
			$orderList=$ord->getOrderList(empty($s) ? '' : $s);
			$page=$ord->page();
			include(ADMINI_TPL.'order_list.html');
			break;
		case "detail"://订单详细
			$detail=$ord->getOrderDetail($ordid);
			$proDetail=$pro->getTicketDetail($detail['Tord_tkt_id']);//门票详细
			include(ADMINI_TPL.'order_detail.html');
			break;
		case "sendOrd"://下订单
			if($_SESSION['flag']==0){
				Alert('订单已经预订成功，请去付款');
				echo js('window.close();');
				exit();
			}
			$ord->sendOrder();
			break;
		case "sendOrdPay"://下单成功之后跳转的支付
			$uinfo=getUserInfo();//用户信息
			$detail=$ord->getOrderDetail($ordid);//订单详细
			$proDetail=$pro->getTicketDetail($detail['Tord_tkt_id']);//门票详细
			if($proDetail['Tkt_shipping']==1){
				$freight=$proDetail['Tkt_freight'];
			}else{
				$freight=0;	
			}
			$zjprice=$detail['Tord_price3']*$detail['Tord_num']+$freight;//订单总价
			include(ADMINI_TPL.'orderPay.html');	
			break;
		case "ordPay":
			$uinfo=getUserInfo();//用户信息
			$oinfo=$ord->getOrderDetail($id);//订单信息
			$tinfo=$pro->getTicketDetail($oinfo['Tord_tkt_id']);//门票信息
			$allPrice=$oinfo['Tord_num']*$tinfo['Tkt_price3']+$tinfo['Tkt_freight'];
			$ord->ordpay($id,$allPrice);//下单成功之后跳转的支付
			break;
		default:
			$_SESSION['flag']=1;
			$proDetail=$pro->getTicketDetail($id);//门票相关的
			$dateList=perDate($proDetail['Tkt_starttime'],$proDetail['Tkt_endtime'],strtotime(date('Y-m-d H:i:s')));
			include(ADMINI_TPL.'order.html');
			break;
	}
	
?>